# -*- coding: utf-8 -*- 
#
# Description:
#
#  Definiton
#
#
#
# Changes:
#
# 2012-01-10
# Initial Commit
#
#
# Copyright 2010-2012, WyDev Team.
# Author: Polo35 (polo35580@hotmail.fr)
#
# Licenced under Academic Free License version 3.0
# Review WyGui README & LICENSE files for further details.

nname: 0
n 0(None)[return self.get_item_list('titles_list')
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb76dd9ac>}
nname: 0
n 0(None)[return self.get_item_list('titles_list')
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb76ddaac>}
nname: 245
n 245(None)[self.set_items(titles, 'titles_list', 0)
]:
	i: 103(AL), 244()
	o: 

nname: 244
n 244(None)[]:
	i: 129(AF), 241()
	o: 245()

nname: 241
n 241(None)[]:
	i: 239(AE)
	o: 244()

nname: 239
n 239(None)[]:
	i: 194(f), 204()
	o: 241(AE)

nname: 204
n 204(None)[titles.append(Item(name='', type_=''))
continue
]:
	i: 194(t)
	o: 239()

nname: 194
n 194(<dummy_ex3> EXC_MATCH AttributeError)[]:
	i: 140(except), 146()
	o: 204(t), 239(f)

nname: 146
n 146(None)[title_item = Item(name=i.title, type_='info_%s' % i.field)
titles.append(title_item)
continue
]:
	i: 140(try)
	o: 194()

nname: 140
n 140(None)[for i in self['main_list']:
]:
	i: 129(for)
	o: 146(try), 194(except)

nname: 129
n 129(None)[]:
	i: 103(loop)
	o: 140(for), 244(AF)

nname: 103
n 103(None)[self.set_items(data, 'main_list')
self._set_options_list()
titles = []
]:
	i: 16(t), 99()
	o: 129(loop), 245(AL)

nname: 99
n 99(None)[]:
	i: 16(f)
	o: 103()

nname: 16
n 16(data)[self.eventhandler = eventhandler
ContextMenu.__init__(self, name, type=type)
self.item = item
self._getitems_keywords.update({'titles_list': (lambda : self.get_item_list('titles_list'))})
]:
	i: 0(t), 6()
	o: 99(f), 103(t)

nname: 6
n 6(None)[]:
	i: 0(f)
	o: 16()

nname: 0
n 0(eventhandler)[]:
	i: 
	o: 6(f), 16(t)

nname: 245
n 245(None)[self.set_items(titles, 'titles_list', 0)
]:
	i: 103(AL), 129(AF), 194(AE)
	o: 

nname: 194
n 194(None)[except AttributeError:
	titles.append(Item(name='', type_=''))
	continue
]:
	i: 140()
	o: 245(AE)

nname: 140
n 140(None)[for i in self['main_list']:
try:
	title_item = Item(name=i.title, type_='info_%s' % i.field)
	titles.append(title_item)
	continue
]:
	i: 129(for)
	o: 194()

nname: 129
n 129(None)[]:
	i: 103(loop)
	o: 140(for), 245(AF)

nname: 103
n 103(None)[self.set_items(data, 'main_list')
self._set_options_list()
titles = []
]:
	i: 0(t)
	o: 129(loop), 245(AL)

nname: 0
n 0(None)[if not eventhandler:
	pass
self.eventhandler = eventhandler
ContextMenu.__init__(self, name, type=type)
self.item = item
self._getitems_keywords.update({'titles_list': (lambda : self.get_item_list('titles_list'))})
if not data:
	pass
]:
	i: 
	o: 103()

nname: 245
n 245(None)[self.set_items(titles, 'titles_list', 0)
]:
	i: 0(AL), 129(AF), 140(AE)
	o: 

nname: 140
n 140(None)[for i in self['main_list']:
try:
	title_item = Item(name=i.title, type_='info_%s' % i.field)
	titles.append(title_item)
	continue
except AttributeError:
	titles.append(Item(name='', type_=''))
	continue
]:
	i: 129(for)
	o: 245(AE)

nname: 129
n 129(None)[]:
	i: 0(loop)
	o: 140(for), 245(AF)

nname: 0
n 0(None)[if not eventhandler:
	pass
self.eventhandler = eventhandler
ContextMenu.__init__(self, name, type=type)
self.item = item
self._getitems_keywords.update({'titles_list': (lambda : self.get_item_list('titles_list'))})
if not data:
	pass
self.set_items(data, 'main_list')
self._set_options_list()
titles = []
]:
	i: 
	o: 129(loop), 245(AL)

self.nodes: {0: <unpyclib.structure.node instance at 0xb76dd42c>, 129: <unpyclib.structure.node instance at 0xb76d92cc>, 140: <unpyclib.structure.node instance at 0xb76ddeec>, 245: <unpyclib.structure.node instance at 0xb76d96cc>}
nname: 39
n 39(None)[]:
	i: 3(), 30(), 37(AE)
	o: 

nname: 37
n 37(None)[]:
	i: 20(f)
	o: 39(AE)

nname: 30
n 30(None)[]:
	i: 20(t)
	o: 39()

nname: 20
n 20(<dummy_ex3> EXC_MATCH AttributeError)[]:
	i: 0(except)
	o: 30(t), 37(f)

nname: 3
n 3(None)[self.selected.execute()
]:
	i: 0(try)
	o: 39()

nname: 0
n 0(None)[]:
	i: 
	o: 3(try), 20(except)

nname: 20
n 20(None)[except AttributeError:
	pass
]:
	i: 0()
	o: 

nname: 0
n 0(None)[try:
	self.selected.execute()
]:
	i: 
	o: 20()

nname: 0
n 0(None)[try:
	self.selected.execute()
except AttributeError:
	pass
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb7755a6c>}
nname: 6
n 6(None)[__doc__ = 'Generic information menu.'
def __init__(self, item, data, name='Media information menu', eventhandler=None, type='media_info'):
	if not eventhandler:
		pass
	self.eventhandler = eventhandler
	ContextMenu.__init__(self, name, type=type)
	self.item = item
	self._getitems_keywords.update({'titles_list': (lambda : self.get_item_list('titles_list'))})
	if not data:
		pass
	self.set_items(data, 'main_list')
	self._set_options_list()
	titles = []

def execute_selected(self):
	try:
		self.selected.execute()
	except AttributeError:
		pass

]:
	i: 
	o: 

self.nodes: {6: <unpyclib.structure.node instance at 0xb774cf2c>}
nname: 0
n 0(None)[data = [InfoItem(item, _('Favorites list'), 'favorite_list', False), InfoItem(item, _('Conditonal Access Status'), 'cas', False)]
InfoMenu.__init__(self, item, data, name, ChannelInfoMenuEventHandler(self), type='tv_info')
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb775592c>}
nname: 6
n 6(None)[__doc__ = 'Information menu for a ChannelItem.'
def __init__(self, item, name='Channel information menu'):
	data = [InfoItem(item, _('Favorites list'), 'favorite_list', False), InfoItem(item, _('Conditonal Access Status'), 'cas', False)]
	InfoMenu.__init__(self, item, data, name, ChannelInfoMenuEventHandler(self), type='tv_info')

]:
	i: 
	o: 

self.nodes: {6: <unpyclib.structure.node instance at 0xb774cf2c>}
nname: 184
n 184(None)[InfoMenu.__init__(self, item, data, name, type='tv_info')
]:
	i: 124(), 183()
	o: 

nname: 183
n 183(None)[]:
	i: 0&109(f)
	o: 184()

nname: 124
n 124(None)[data.extend((ProtectionsActionItem(item, self, _('Hidden')), ParentalRatingActionItem(item, self, _('Rating'))))
]:
	i: 0&109(t)
	o: 184()

nname: 0&109
n 0&109(user_config['security']['parental_control'] and user_config['security']['parent_mode'])[info = {'last_scan_date': strftime(get_date_format(), localtime(user_config['tv']['last_scan_time']))}
data = [InfoItem(item, _('Number of channels'), 'childCount', False), InfoItem(info, _('Latest scan date'), 'last_scan_date', False)]
]:
	i: 
	o: 124(t), 183(f)

nname: 0&109
n 0&109(None)[info = {'last_scan_date': strftime(get_date_format(), localtime(user_config['tv']['last_scan_time']))}
data = [InfoItem(item, _('Number of channels'), 'childCount', False), InfoItem(info, _('Latest scan date'), 'last_scan_date', False)]
if user_config['security']['parental_control'] and user_config['security']['parent_mode']:
	data.extend((ProtectionsActionItem(item, self, _('Hidden')), ParentalRatingActionItem(item, self, _('Rating'))))
InfoMenu.__init__(self, item, data, name, type='tv_info')
]:
	i: 
	o: 

self.nodes: {'0&109': <unpyclib.structure.node instance at 0xb7755c2c>}
nname: 6
n 6(None)[__doc__ = 'Information menu for the All Channels List.'
def __init__(self, item, name='Full channels list information menu'):
	info = {'last_scan_date': strftime(get_date_format(), localtime(user_config['tv']['last_scan_time']))}
	data = [InfoItem(item, _('Number of channels'), 'childCount', False), InfoItem(info, _('Latest scan date'), 'last_scan_date', False)]
	if user_config['security']['parental_control'] and user_config['security']['parent_mode']:
		data.extend((ProtectionsActionItem(item, self, _('Hidden')), ParentalRatingActionItem(item, self, _('Rating'))))
	InfoMenu.__init__(self, item, data, name, type='tv_info')

]:
	i: 
	o: 

self.nodes: {6: <unpyclib.structure.node instance at 0xb774cd0c>}
nname: 330
n 330(None)[InfoMenu.__init__(self, item, data, name, type='tv_info')
]:
	i: 307(), 321(), 328(AE)
	o: 

nname: 328
n 328(None)[]:
	i: 311(f)
	o: 330(AE)

nname: 321
n 321(None)[]:
	i: 311(t)
	o: 330()

nname: 311
n 311(<dummy_ex3> EXC_MATCH AttributeError)[]:
	i: 0(except)
	o: 321(t), 328(f)

nname: 307
n 307(None)[]:
	i: 271(), 306()
	o: 330()

nname: 306
n 306(None)[]:
	i: 165(f)
	o: 307()

nname: 271
n 271(None)[data.append(RecordActivationItem(item, self, _('Activation')))
]:
	i: 165(t)
	o: 307()

nname: 165
n 165(item.remaining_count > 1)[repeat_info = {'period': item.period, 'remaining_count': item.remaining_count}
data.extend([InfoItem(repeat_info, _('Repeat'), 'period', False), InfoItem(repeat_info, _('Remaining recordings'), 'remaining_count', False)])
]:
	i: 0(try)
	o: 271(t), 306(f)

nname: 0
n 0(None)[rec_info = {'start_date': strftime(_('%A %d %B'), localtime(item.record.start_time)), 'start_time': seconds_to_hhmm(item.record.start_time), 'end_time': seconds_to_hhmm(item.record.stop_time)}
data = [InfoItem(rec_info, _('Date'), 'start_date', False), InfoItem(rec_info, _('Start time'), 'start_time', False), InfoItem(rec_info, _('End time'), 'end_time', False)]
]:
	i: 
	o: 165(try), 311(except)

nname: 330
n 330(None)[InfoMenu.__init__(self, item, data, name, type='tv_info')
]:
	i: 311(), 0()
	o: 

nname: 311
n 311(None)[except AttributeError:
	pass
]:
	i: 0()
	o: 330()

nname: 330
n 330(None)[InfoMenu.__init__(self, item, data, name, type='tv_info')
]:
	i: 311(), 0()
	o: 

nname: 0
n 0(None)[rec_info = {'start_date': strftime(_('%A %d %B'), localtime(item.record.start_time)), 'start_time': seconds_to_hhmm(item.record.start_time), 'end_time': seconds_to_hhmm(item.record.stop_time)}
data = [InfoItem(rec_info, _('Date'), 'start_date', False), InfoItem(rec_info, _('Start time'), 'start_time', False), InfoItem(rec_info, _('End time'), 'end_time', False)]
try:
	repeat_info = {'period': item.period, 'remaining_count': item.remaining_count}
	data.extend([InfoItem(repeat_info, _('Repeat'), 'period', False), InfoItem(repeat_info, _('Remaining recordings'), 'remaining_count', False)])
	if item.remaining_count > 1:
		data.append(RecordActivationItem(item, self, _('Activation')))
]:
	i: 
	o: 330(), 311()

self.nodes: {0: <unpyclib.structure.node instance at 0xb76d92cc>, 330: <unpyclib.structure.node instance at 0xb76dd24c>, 311: <unpyclib.structure.node instance at 0xb76d96cc>}
nname: 6
n 6(None)[__doc__ = 'Information menu for a ScheduledRecordItem.'
def __init__(self, item, name='Scheduled Record information menu'):
	rec_info = {'start_date': strftime(_('%A %d %B'), localtime(item.record.start_time)), 'start_time': seconds_to_hhmm(item.record.start_time), 'end_time': seconds_to_hhmm(item.record.stop_time)}
	data = [InfoItem(rec_info, _('Date'), 'start_date', False), InfoItem(rec_info, _('Start time'), 'start_time', False), InfoItem(rec_info, _('End time'), 'end_time', False)]
	try:
		repeat_info = {'period': item.period, 'remaining_count': item.remaining_count}
		data.extend([InfoItem(repeat_info, _('Repeat'), 'period', False), InfoItem(repeat_info, _('Remaining recordings'), 'remaining_count', False)])
		if item.remaining_count > 1:
			data.append(RecordActivationItem(item, self, _('Activation')))

]:
	i: 
	o: 

self.nodes: {6: <unpyclib.structure.node instance at 0xb774ccac>}
nname: 154
n 154(None)[InfoMenu.__init__(self, item, data, name, type='tv_info')
]:
	i: 69(), 153()
	o: 

nname: 153
n 153(None)[]:
	i: 0(f)
	o: 154()

nname: 69
n 69(None)[next_record = all_recs[0].record
values = {'start_time': strftime('%Y-%m-%d %H:%M', localtime(next_record.start_time))}
data.append(InfoItem(values, _('Next recording on'), 'start_time', False))
]:
	i: 0(t)
	o: 154()

nname: 0
n 0(all_recs)[all_recs = item.browse()
info = {'num_records': len(all_recs)}
data = [InfoItem(info, _('Number of scheduled recordings'), 'num_records', False)]
]:
	i: 
	o: 69(t), 153(f)

nname: 0
n 0(None)[all_recs = item.browse()
info = {'num_records': len(all_recs)}
data = [InfoItem(info, _('Number of scheduled recordings'), 'num_records', False)]
if all_recs:
	next_record = all_recs[0].record
	values = {'start_time': strftime('%Y-%m-%d %H:%M', localtime(next_record.start_time))}
	data.append(InfoItem(values, _('Next recording on'), 'start_time', False))
InfoMenu.__init__(self, item, data, name, type='tv_info')
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb77556ac>}
nname: 6
n 6(None)[__doc__ = 'Information menu for the ScheduledRecordRootItem.'
def __init__(self, item, name='Scheduled Records Root information menu'):
	all_recs = item.browse()
	info = {'num_records': len(all_recs)}
	data = [InfoItem(info, _('Number of scheduled recordings'), 'num_records', False)]
	if all_recs:
		next_record = all_recs[0].record
		values = {'start_time': strftime('%Y-%m-%d %H:%M', localtime(next_record.start_time))}
		data.append(InfoItem(values, _('Next recording on'), 'start_time', False))
	InfoMenu.__init__(self, item, data, name, type='tv_info')

]:
	i: 
	o: 

self.nodes: {6: <unpyclib.structure.node instance at 0xb774cdcc>}
nname: 111
n 111(None)[self.set_items([self.action_container], 'main_list')
self._set_options_list()
self.focus_next()
]:
	i: 16(t), 107()
	o: 

nname: 107
n 107(None)[]:
	i: 16(f)
	o: 111()

nname: 16
n 16([self.action_container])[self.eventhandler = eventhandler
ContextMenu.__init__(self, name, type=type)
self.item = item
self.parent_menu = parent_menu
self.action_container = ParentalRatingActionItem(item, self, _('Rating'))
]:
	i: 0(t), 6()
	o: 107(f), 111(t)

nname: 6
n 6(None)[]:
	i: 0(f)
	o: 16()

nname: 0
n 0(eventhandler)[]:
	i: 
	o: 6(f), 16(t)

nname: 111
n 111(None)[self.set_items([self.action_container], 'main_list')
self._set_options_list()
self.focus_next()
]:
	i: 0(t)
	o: 

nname: 0
n 0(None)[if not eventhandler:
	pass
self.eventhandler = eventhandler
ContextMenu.__init__(self, name, type=type)
self.item = item
self.parent_menu = parent_menu
self.action_container = ParentalRatingActionItem(item, self, _('Rating'))
if not [self.action_container]:
	pass
]:
	i: 
	o: 111()

nname: 0
n 0(None)[if not eventhandler:
	pass
self.eventhandler = eventhandler
ContextMenu.__init__(self, name, type=type)
self.item = item
self.parent_menu = parent_menu
self.action_container = ParentalRatingActionItem(item, self, _('Rating'))
if not [self.action_container]:
	pass
self.set_items([self.action_container], 'main_list')
self._set_options_list()
self.focus_next()
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb7755c8c>}
nname: 0
n 0(None)[]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb77552ac>}
nname: 0
n 0(None)[return self.action_container.name
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb775526c>}
nname: 0
n 0(None)[self.selected.execute()
self.hide()
self.parent_menu.rating_callback()
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb775582c>}
nname: 0
n 0(None)[]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb775526c>}
nname: 6
n 6(None)[__doc__ = ' Menu to display available rating choices over InfoMenu '
def __init__(self, item, parent_menu, name='Media Rating menu', eventhandler=None, type='rating_info'):
	if not eventhandler:
		pass
	self.eventhandler = eventhandler
	ContextMenu.__init__(self, name, type=type)
	self.item = item
	self.parent_menu = parent_menu
	self.action_container = ParentalRatingActionItem(item, self, _('Rating'))
	if not [self.action_container]:
		pass
	self.set_items([self.action_container], 'main_list')
	self._set_options_list()
	self.focus_next()

def focus_previous(self):
	pass

def get_current_rating(self):
	return self.action_container.name

def execute_selected(self):
	self.selected.execute()
	self.hide()
	self.parent_menu.rating_callback()

def clear(self):
	pass

]:
	i: 
	o: 

self.nodes: {6: <unpyclib.structure.node instance at 0xb774cecc>}
nname: 0
n 0(None)[return None
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb76ddb0c>}
nname: 0
n 0(None)[return None
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb76ddf2c>}
nname: 330
n 330(None)[return None
]:
	i: 265(), 305(), 328(AE)
	o: 

nname: 328
n 328(None)[]:
	i: 295(f)
	o: 330(AE)

nname: 305
n 305(None)[log.warn('%s.watch failed !', item)
]:
	i: 295(t)
	o: 330()

nname: 295
n 295(<dummy_ex3> EXC_MATCH AttributeError)[]:
	i: 180(except)
	o: 305(t), 328(f)

nname: 265
n 265(None)[item.watch(self._selection_changed)
item.async_media_update()
]:
	i: 180(try)
	o: 330()

nname: 180
n 180(None)[InfoMenu.__init__(self, item, data, name, type='media_info')
def self._getitems_keywords['hd_info_icon']():
	return None

def self._getitems_keywords['snd_info_icon']():
	return None

log.debug('InfoWindow for %s: %s', item, item.wymedia_resource)
]:
	i: 45(), 179()
	o: 265(try), 295(except)

nname: 179
n 179(None)[]:
	i: 0&23&38(f)
	o: 180()

nname: 45
n 45(None)[self.rate_menu = RatingInfoMenu(item, self)
current_rating = self.rate_menu.get_current_rating()
rating_launcher = ActionItem(current_rating, type_='info', menu=self, display_type=None, action=self.show_rating, args=(), kwargs={})
rating_launcher.title = _('Rating')
rating_launcher.field = 'rating'
data.append(rating_launcher)
self.rating_launcher = rating_launcher
]:
	i: 0&23&38(t)
	o: 180()

nname: 0&23&38
n 0&23&38(user_config['security']['parental_control'] and user_config['security']['parent_mode'] and data)[self.rating_launcher = None
]:
	i: 
	o: 45(t), 179(f)

nname: 295
n 295(None)[except AttributeError:
	log.warn('%s.watch failed !', item)
return None
]:
	i: 0&23&38()
	o: 

nname: 0&23&38
n 0&23&38(None)[self.rating_launcher = None
if user_config['security']['parental_control'] and user_config['security']['parent_mode'] and data:
	self.rate_menu = RatingInfoMenu(item, self)
	current_rating = self.rate_menu.get_current_rating()
	rating_launcher = ActionItem(current_rating, type_='info', menu=self, display_type=None, action=self.show_rating, args=(), kwargs={})
	rating_launcher.title = _('Rating')
	rating_launcher.field = 'rating'
	data.append(rating_launcher)
	self.rating_launcher = rating_launcher
InfoMenu.__init__(self, item, data, name, type='media_info')
def self._getitems_keywords['hd_info_icon']():
	return None

def self._getitems_keywords['snd_info_icon']():
	return None

log.debug('InfoWindow for %s: %s', item, item.wymedia_resource)
try:
	item.watch(self._selection_changed)
	item.async_media_update()
]:
	i: 
	o: 295()

nname: 0&23&38
n 0&23&38(None)[self.rating_launcher = None
if user_config['security']['parental_control'] and user_config['security']['parent_mode'] and data:
	self.rate_menu = RatingInfoMenu(item, self)
	current_rating = self.rate_menu.get_current_rating()
	rating_launcher = ActionItem(current_rating, type_='info', menu=self, display_type=None, action=self.show_rating, args=(), kwargs={})
	rating_launcher.title = _('Rating')
	rating_launcher.field = 'rating'
	data.append(rating_launcher)
	self.rating_launcher = rating_launcher
InfoMenu.__init__(self, item, data, name, type='media_info')
def self._getitems_keywords['hd_info_icon']():
	return None

def self._getitems_keywords['snd_info_icon']():
	return None

log.debug('InfoWindow for %s: %s', item, item.wymedia_resource)
try:
	item.watch(self._selection_changed)
	item.async_media_update()
except AttributeError:
	log.warn('%s.watch failed !', item)
return None
]:
	i: 
	o: 

self.nodes: {'0&23&38': <unpyclib.structure.node instance at 0xb76dde2c>}
nname: 80
n 80(None)[]:
	i: 65(), 79()
	o: 

nname: 79
n 79(None)[]:
	i: 0&30&46(f)
	o: 80()

nname: 65
n 65(None)[self.execute_selected()
]:
	i: 0&30&46(t)
	o: 80()

nname: 0&30&46
n 0&30&46(ret and self.active_list == 'main_list' and self.rating_launcher == self.selected)[ret = ContextMenu.select(self, item, list_name, force_pos)
]:
	i: 
	o: 65(t), 79(f)

nname: 0&30&46
n 0&30&46(None)[ret = ContextMenu.select(self, item, list_name, force_pos)
if ret and self.active_list == 'main_list' and self.rating_launcher == self.selected:
	self.execute_selected()
]:
	i: 
	o: 

self.nodes: {'0&30&46': <unpyclib.structure.node instance at 0xb77558ac>}
nname: 0
n 0(None)[self.rate_menu.show()
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb775552c>}
nname: 0
n 0(None)[self.selected.name = self.rate_menu.get_current_rating()
louie_send('main_list', sender=self, action='reset', value=self['main_list'], position=self.selected_pos)
self.rate_menu = RatingInfoMenu(self.item, self)
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb77558cc>}
nname: 72
n 72(None)[louie_send('main_list', sender=self, action='reset', value=self['main_list'])
]:
	i: 0(AL), 71()
	o: 

nname: 71
n 71(None)[]:
	i: 19(AF), 67()
	o: 72()

nname: 67
n 67(None)[]:
	i: 35(f), 53()
	o: 71()

nname: 53
n 53(None)[info.reload()
continue
]:
	i: 35(t)
	o: 67()

nname: 35
n 35(isinstance(info, InfoItem))[for info in self.get_item_list('main_list'):
]:
	i: 19(for)
	o: 53(t), 67(f)

nname: 19
n 19(None)[]:
	i: 0(loop)
	o: 35(for), 71(AF)

nname: 0
n 0(None)[log.debug('%s changed, reloading InfoWindow', item)
]:
	i: 
	o: 19(loop), 72(AL)

nname: 72
n 72(None)[louie_send('main_list', sender=self, action='reset', value=self['main_list'])
]:
	i: 0(AL), 19(AF), 35()
	o: 

nname: 35
n 35(None)[for info in self.get_item_list('main_list'):
if isinstance(info, InfoItem):
	info.reload()
	continue
]:
	i: 19(for)
	o: 72()

nname: 19
n 19(None)[]:
	i: 0(loop)
	o: 35(for), 72(AF)

nname: 0
n 0(None)[log.debug('%s changed, reloading InfoWindow', item)
]:
	i: 
	o: 19(loop), 72(AL)

nname: 35
n 35(None)[for info in self.get_item_list('main_list'):
	if isinstance(info, InfoItem):
		info.reload()
		continue
louie_send('main_list', sender=self, action='reset', value=self['main_list'])
]:
	i: 0(for)
	o: 

nname: 0
n 0(None)[log.debug('%s changed, reloading InfoWindow', item)
]:
	i: 
	o: 35(for)

nname: 0
n 0(None)[log.debug('%s changed, reloading InfoWindow', item)
for info in self.get_item_list('main_list'):
	if isinstance(info, InfoItem):
		info.reload()
		continue
louie_send('main_list', sender=self, action='reset', value=self['main_list'])
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb7755e4c>}
nname: 0
n 0(None)[InfoMenu.clear(self)
ContextMenu.clear(self.rate_menu)
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb77552cc>}
nname: 6
n 6(None)[__doc__ = ' Defines common methods for accessing wymedia attributes '
def __init__(self, item, data, name):
	self.rating_launcher = None
	if user_config['security']['parental_control'] and user_config['security']['parent_mode'] and data:
		self.rate_menu = RatingInfoMenu(item, self)
		current_rating = self.rate_menu.get_current_rating()
		rating_launcher = ActionItem(current_rating, type_='info', menu=self, display_type=None, action=self.show_rating, args=(), kwargs={})
		rating_launcher.title = _('Rating')
		rating_launcher.field = 'rating'
		data.append(rating_launcher)
		self.rating_launcher = rating_launcher
	InfoMenu.__init__(self, item, data, name, type='media_info')
	def self._getitems_keywords['hd_info_icon']():
		return None

	def self._getitems_keywords['snd_info_icon']():
		return None

	log.debug('InfoWindow for %s: %s', item, item.wymedia_resource)
	try:
		item.watch(self._selection_changed)
		item.async_media_update()
	except AttributeError:
		log.warn('%s.watch failed !', item)
	return None

def select(self, item, list_name=None, force_pos=False):
	ret = ContextMenu.select(self, item, list_name, force_pos)
	if ret and self.active_list == 'main_list' and self.rating_launcher == self.selected:
		self.execute_selected()

def show_rating(self):
	self.rate_menu.show()

def rating_callback(self):
	self.selected.name = self.rate_menu.get_current_rating()
	louie_send('main_list', sender=self, action='reset', value=self['main_list'], position=self.selected_pos)
	self.rate_menu = RatingInfoMenu(self.item, self)

def _selection_changed(self, item):
	log.debug('%s changed, reloading InfoWindow', item)
	for info in self.get_item_list('main_list'):
		if isinstance(info, InfoItem):
			info.reload()
			continue
	louie_send('main_list', sender=self, action='reset', value=self['main_list'])

def clear(self):
	InfoMenu.clear(self)
	ContextMenu.clear(self.rate_menu)

]:
	i: 
	o: 

self.nodes: {6: <unpyclib.structure.node instance at 0xb774ce2c>}
nname: 0
n 0(None)[data = [InfoItem(item, _('Title'), 'metadata_title', True), InfoItem(item, _('Artist'), 'author', True), InfoItem(item, _('Genre'), 'genre', True), InfoItem(item, _('Album'), 'album', True), InfoItem(item, _('Track'), 'track', True), InfoItem(item, _('Year'), 'year', True), InfoItem(item, _('Format'), 'audio_codec'), InfoItem(item, _('Bitrate'), 'bitrate'), InfoItem(item, _('Duration'), 'duration'), InfoItem(item, _('Size'), 'size'), InfoItem(item, _('Belongs to playlist'), 'playlists'), InfoItem(item, _('Import date'), 'date')]
MediaItemInfoMenu.__init__(self, item, data, name)
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb77557cc>}
nname: 6
n 6(None)[__doc__ = ' Information menu for a AudioItem '
def __init__(self, item, name='AudioItem information menu'):
	data = [InfoItem(item, _('Title'), 'metadata_title', True), InfoItem(item, _('Artist'), 'author', True), InfoItem(item, _('Genre'), 'genre', True), InfoItem(item, _('Album'), 'album', True), InfoItem(item, _('Track'), 'track', True), InfoItem(item, _('Year'), 'year', True), InfoItem(item, _('Format'), 'audio_codec'), InfoItem(item, _('Bitrate'), 'bitrate'), InfoItem(item, _('Duration'), 'duration'), InfoItem(item, _('Size'), 'size'), InfoItem(item, _('Belongs to playlist'), 'playlists'), InfoItem(item, _('Import date'), 'date')]
	MediaItemInfoMenu.__init__(self, item, data, name)

]:
	i: 
	o: 

self.nodes: {6: <unpyclib.structure.node instance at 0xb774ccac>}
nname: 197
n 197(None)[data.append(InfoItem(item, _('Cover'), 'cover'))
MediaItemInfoMenu.__init__(self, item, data, name)
self._getitems_keywords['hd_info_icon'] = self._get_hd_info_icon
self._getitems_keywords['snd_info_icon'] = self._get_snd_info_icon
]:
	i: 130(), 165()
	o: 

nname: 165
n 165(None)[data.append(InfoItem(item, _('Importation date'), 'date'))
]:
	i: 0(f)
	o: 197()

nname: 130
n 130(None)[data.append(InfoItem(item, _('Record date'), 'recordedStartDateTime'))
]:
	i: 0(t)
	o: 197()

nname: 0
n 0(item['class'].endswith('tvRecord'))[data = [InfoItem(item, _('Size'), 'size'), InfoItem(item, _('Codec'), 'video_codec'), InfoItem(item, _('Resolution'), 'resolution'), InfoItem(item, _('Sound track'), 'nrAudioChannels'), InfoItem(item, _('Artist'), 'author')]
]:
	i: 
	o: 130(t), 165(f)

nname: 0
n 0(None)[data = [InfoItem(item, _('Size'), 'size'), InfoItem(item, _('Codec'), 'video_codec'), InfoItem(item, _('Resolution'), 'resolution'), InfoItem(item, _('Sound track'), 'nrAudioChannels'), InfoItem(item, _('Artist'), 'author')]
if item['class'].endswith('tvRecord'):
	data.append(InfoItem(item, _('Record date'), 'recordedStartDateTime'))
else:
	data.append(InfoItem(item, _('Importation date'), 'date'))
data.append(InfoItem(item, _('Cover'), 'cover'))
MediaItemInfoMenu.__init__(self, item, data, name)
self._getitems_keywords['hd_info_icon'] = self._get_hd_info_icon
self._getitems_keywords['snd_info_icon'] = self._get_snd_info_icon
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb76dd64c>}
nname: 0
n 0(None)[MediaItemInfoMenu._selection_changed(self, item)
louie_send('hd_info_icon', sender=self, action='update', value=self._get_hd_info_icon())
louie_send('snd_info_icon', sender=self, action='update', value=self._get_snd_info_icon())
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb76dd36c>}
nname: 60
n 60(None)[return ico
]:
	i: 45(JA), 55(), 59()
	o: 

nname: 59
n 59(None)[]:
	i: 0(f)
	o: 60()

nname: 55
n 55(None)[]:
	i: 19(f)
	o: 60()

nname: 45
n 45(None)[ico = 'tvplayer_videoformathd.png'
]:
	i: 19(t)
	o: 60(JA)

nname: 19
n 19(int(self.item['height']) > 700)[]:
	i: 0(t)
	o: 45(t), 55(f)

nname: 0
n 0(self.item['height'])[ico = None
]:
	i: 
	o: 19(t), 59(f)

nname: 0
n 0(None)[ico = None
if self.item['height']:
	if int(self.item['height']) > 700:
		ico = 'tvplayer_videoformathd.png'
return ico
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb76ddd6c>}
nname: 60
n 60(None)[return ico
]:
	i: 45(JA), 55(), 59()
	o: 

nname: 59
n 59(None)[]:
	i: 0(f)
	o: 60()

nname: 55
n 55(None)[]:
	i: 19(f)
	o: 60()

nname: 45
n 45(None)[ico = 'tvplayer_audio51.png'
]:
	i: 19(t)
	o: 60(JA)

nname: 19
n 19(int(self.item['nrAudioChannels']) > 5)[]:
	i: 0(t)
	o: 45(t), 55(f)

nname: 0
n 0(self.item['nrAudioChannels'])[ico = None
]:
	i: 
	o: 19(t), 59(f)

nname: 0
n 0(None)[ico = None
if self.item['nrAudioChannels']:
	if int(self.item['nrAudioChannels']) > 5:
		ico = 'tvplayer_audio51.png'
return ico
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb76dd30c>}
nname: 6
n 6(None)[__doc__ = ' Information menu for a VideoItem '
def __init__(self, item, name='VideoItem information menu'):
	data = [InfoItem(item, _('Size'), 'size'), InfoItem(item, _('Codec'), 'video_codec'), InfoItem(item, _('Resolution'), 'resolution'), InfoItem(item, _('Sound track'), 'nrAudioChannels'), InfoItem(item, _('Artist'), 'author')]
	if item['class'].endswith('tvRecord'):
		data.append(InfoItem(item, _('Record date'), 'recordedStartDateTime'))
	else:
		data.append(InfoItem(item, _('Importation date'), 'date'))
	data.append(InfoItem(item, _('Cover'), 'cover'))
	MediaItemInfoMenu.__init__(self, item, data, name)
	self._getitems_keywords['hd_info_icon'] = self._get_hd_info_icon
	self._getitems_keywords['snd_info_icon'] = self._get_snd_info_icon

def _selection_changed(self, item):
	MediaItemInfoMenu._selection_changed(self, item)
	louie_send('hd_info_icon', sender=self, action='update', value=self._get_hd_info_icon())
	louie_send('snd_info_icon', sender=self, action='update', value=self._get_snd_info_icon())

def _get_hd_info_icon(self):
	ico = None
	if self.item['height']:
		if int(self.item['height']) > 700:
			ico = 'tvplayer_videoformathd.png'
	return ico

def _get_snd_info_icon(self):
	ico = None
	if self.item['nrAudioChannels']:
		if int(self.item['nrAudioChannels']) > 5:
			ico = 'tvplayer_audio51.png'
	return ico

]:
	i: 
	o: 

self.nodes: {6: <unpyclib.structure.node instance at 0xb774cf4c>}
nname: 0
n 0(None)[data = [InfoItem(item, _('Size'), 'size'), InfoItem(item, _('Resolution'), 'resolution'), InfoItem(item, _('Camera Model'), 'exif_model')]
MediaItemInfoMenu.__init__(self, item, data, name)
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb76dda2c>}
nname: 6
n 6(None)[__doc__ = ' Information menu for a ImageItem '
def __init__(self, item, name='ImageItem information menu'):
	data = [InfoItem(item, _('Size'), 'size'), InfoItem(item, _('Resolution'), 'resolution'), InfoItem(item, _('Camera Model'), 'exif_model')]
	MediaItemInfoMenu.__init__(self, item, data, name)

]:
	i: 
	o: 

self.nodes: {6: <unpyclib.structure.node instance at 0xb774cd0c>}
nname: 0
n 0(None)[data = [InfoItem(item, _('Link'), 'link'), InfoItem(item, _('URI'), 'uri')]
MediaItemInfoMenu.__init__(self, item, data, name)
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb76ddfec>}
nname: 6
n 6(None)[__doc__ = 'Information menu for NetFeedItem.'
def __init__(self, item, name='NetFeedItem information menu'):
	data = [InfoItem(item, _('Link'), 'link'), InfoItem(item, _('URI'), 'uri')]
	MediaItemInfoMenu.__init__(self, item, data, name)

]:
	i: 
	o: 

self.nodes: {6: <unpyclib.structure.node instance at 0xb774cc4c>}
nname: 0
n 0(None)[data = [InfoItem(item, _('Author'), 'author'), InfoItem(item, _('Link'), 'link'), InfoItem(item, _('URI'), 'uri')]
MediaItemInfoMenu.__init__(self, item, data, name)
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb76dd42c>}
nname: 6
n 6(None)[__doc__ = 'Information menu for NetItem.'
def __init__(self, item, name='NetItem information menu'):
	data = [InfoItem(item, _('Author'), 'author'), InfoItem(item, _('Link'), 'link'), InfoItem(item, _('URI'), 'uri')]
	MediaItemInfoMenu.__init__(self, item, data, name)

]:
	i: 
	o: 

self.nodes: {6: <unpyclib.structure.node instance at 0xb774c92c>}
nname: 0
n 0(None)[data = [InfoItem(item, _('Number of files'), 'childs'), InfoItem(item, _('Creation date'), 'date')]
MediaItemInfoMenu.__init__(self, item, data, name)
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb76dd28c>}
nname: 6
n 6(None)[__doc__ = ' Information menu for a DirItem '
def __init__(self, item, name='DirItem information menu'):
	data = [InfoItem(item, _('Number of files'), 'childs'), InfoItem(item, _('Creation date'), 'date')]
	MediaItemInfoMenu.__init__(self, item, data, name)

]:
	i: 
	o: 

self.nodes: {6: <unpyclib.structure.node instance at 0xb774ceec>}
nname: 0
n 0(None)[data = [InfoItem(item, _('Number of tracks'), 'childs'), InfoItem(item, _('Missing tracks'), 'missing'), InfoItem(item, _('Creation date'), 'date')]
MediaItemInfoMenu.__init__(self, item, data, name)
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb76dd30c>}
nname: 6
n 6(None)[__doc__ = ' Information menu for a PlayListItem '
def __init__(self, item, name='PlayList information menu'):
	data = [InfoItem(item, _('Number of tracks'), 'childs'), InfoItem(item, _('Missing tracks'), 'missing'), InfoItem(item, _('Creation date'), 'date')]
	MediaItemInfoMenu.__init__(self, item, data, name)

]:
	i: 
	o: 

self.nodes: {6: <unpyclib.structure.node instance at 0xb774cdac>}
nname: 0
n 0(None)[data = []
MediaItemInfoMenu.__init__(self, item, data, name)
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb76dd3cc>}
nname: 6
n 6(None)[__doc__ = ' Information menu for the markerlist '
def __init__(self, item, name='MarkerList information menu'):
	data = []
	MediaItemInfoMenu.__init__(self, item, data, name)

]:
	i: 
	o: 

self.nodes: {6: <unpyclib.structure.node instance at 0xb774cbac>}
nname: 0
n 0(None)[from __future__ import absolute_import
from time import localtime, strftime
from peewee.messages import send as louie_send
from pygui.eventmanager.menus import InfoMenuEventHandler, ChannelInfoMenuEventHandler
from pygui.facilities.l10n import get_date_format
from pygui.item.core import ActionItem, Item
from pygui.item.info import InfoItem, RecordActivationItem, ProtectionsActionItem, ParentalRatingActionItem
from pygui.config import user_config
from .core import ContextMenu
from peewee.formatters import seconds_to_hhmm
from peewee.debug import GET_LOGGER
log = GET_LOGGER(__name__)
class InfoMenu(ContextMenu):
	__doc__ = 'Generic information menu.'
	def __init__(self, item, data, name='Media information menu', eventhandler=None, type='media_info'):
		if not eventhandler:
			pass
		self.eventhandler = eventhandler
		ContextMenu.__init__(self, name, type=type)
		self.item = item
		self._getitems_keywords.update({'titles_list': (lambda : self.get_item_list('titles_list'))})
		if not data:
			pass
		self.set_items(data, 'main_list')
		self._set_options_list()
		titles = []

	def execute_selected(self):
		try:
			self.selected.execute()
		except AttributeError:
			pass



class ChannelInfoMenu(InfoMenu):
	__doc__ = 'Information menu for a ChannelItem.'
	def __init__(self, item, name='Channel information menu'):
		data = [InfoItem(item, _('Favorites list'), 'favorite_list', False), InfoItem(item, _('Conditonal Access Status'), 'cas', False)]
		InfoMenu.__init__(self, item, data, name, ChannelInfoMenuEventHandler(self), type='tv_info')



class TVInfoMenu(InfoMenu):
	__doc__ = 'Information menu for the All Channels List.'
	def __init__(self, item, name='Full channels list information menu'):
		info = {'last_scan_date': strftime(get_date_format(), localtime(user_config['tv']['last_scan_time']))}
		data = [InfoItem(item, _('Number of channels'), 'childCount', False), InfoItem(info, _('Latest scan date'), 'last_scan_date', False)]
		if user_config['security']['parental_control'] and user_config['security']['parent_mode']:
			data.extend((ProtectionsActionItem(item, self, _('Hidden')), ParentalRatingActionItem(item, self, _('Rating'))))
		InfoMenu.__init__(self, item, data, name, type='tv_info')



class ScheduledRecordInfoMenu(InfoMenu):
	__doc__ = 'Information menu for a ScheduledRecordItem.'
	def __init__(self, item, name='Scheduled Record information menu'):
		rec_info = {'start_date': strftime(_('%A %d %B'), localtime(item.record.start_time)), 'start_time': seconds_to_hhmm(item.record.start_time), 'end_time': seconds_to_hhmm(item.record.stop_time)}
		data = [InfoItem(rec_info, _('Date'), 'start_date', False), InfoItem(rec_info, _('Start time'), 'start_time', False), InfoItem(rec_info, _('End time'), 'end_time', False)]
		try:
			repeat_info = {'period': item.period, 'remaining_count': item.remaining_count}
			data.extend([InfoItem(repeat_info, _('Repeat'), 'period', False), InfoItem(repeat_info, _('Remaining recordings'), 'remaining_count', False)])
			if item.remaining_count > 1:
				data.append(RecordActivationItem(item, self, _('Activation')))



class ScheduledRecordRootInfoMenu(InfoMenu):
	__doc__ = 'Information menu for the ScheduledRecordRootItem.'
	def __init__(self, item, name='Scheduled Records Root information menu'):
		all_recs = item.browse()
		info = {'num_records': len(all_recs)}
		data = [InfoItem(info, _('Number of scheduled recordings'), 'num_records', False)]
		if all_recs:
			next_record = all_recs[0].record
			values = {'start_time': strftime('%Y-%m-%d %H:%M', localtime(next_record.start_time))}
			data.append(InfoItem(values, _('Next recording on'), 'start_time', False))
		InfoMenu.__init__(self, item, data, name, type='tv_info')



class RatingInfoMenu(ContextMenu):
	__doc__ = ' Menu to display available rating choices over InfoMenu '
	def __init__(self, item, parent_menu, name='Media Rating menu', eventhandler=None, type='rating_info'):
		if not eventhandler:
			pass
		self.eventhandler = eventhandler
		ContextMenu.__init__(self, name, type=type)
		self.item = item
		self.parent_menu = parent_menu
		self.action_container = ParentalRatingActionItem(item, self, _('Rating'))
		if not [self.action_container]:
			pass
		self.set_items([self.action_container], 'main_list')
		self._set_options_list()
		self.focus_next()

	def focus_previous(self):
		pass

	def get_current_rating(self):
		return self.action_container.name

	def execute_selected(self):
		self.selected.execute()
		self.hide()
		self.parent_menu.rating_callback()

	def clear(self):
		pass



class MediaItemInfoMenu(InfoMenu):
	__doc__ = ' Defines common methods for accessing wymedia attributes '
	def __init__(self, item, data, name):
		self.rating_launcher = None
		if user_config['security']['parental_control'] and user_config['security']['parent_mode'] and data:
			self.rate_menu = RatingInfoMenu(item, self)
			current_rating = self.rate_menu.get_current_rating()
			rating_launcher = ActionItem(current_rating, type_='info', menu=self, display_type=None, action=self.show_rating, args=(), kwargs={})
			rating_launcher.title = _('Rating')
			rating_launcher.field = 'rating'
			data.append(rating_launcher)
			self.rating_launcher = rating_launcher
		InfoMenu.__init__(self, item, data, name, type='media_info')
		def self._getitems_keywords['hd_info_icon']():
			return None

		def self._getitems_keywords['snd_info_icon']():
			return None

		log.debug('InfoWindow for %s: %s', item, item.wymedia_resource)
		try:
			item.watch(self._selection_changed)
			item.async_media_update()
		except AttributeError:
			log.warn('%s.watch failed !', item)
		return None

	def select(self, item, list_name=None, force_pos=False):
		ret = ContextMenu.select(self, item, list_name, force_pos)
		if ret and self.active_list == 'main_list' and self.rating_launcher == self.selected:
			self.execute_selected()

	def show_rating(self):
		self.rate_menu.show()

	def rating_callback(self):
		self.selected.name = self.rate_menu.get_current_rating()
		louie_send('main_list', sender=self, action='reset', value=self['main_list'], position=self.selected_pos)
		self.rate_menu = RatingInfoMenu(self.item, self)

	def _selection_changed(self, item):
		log.debug('%s changed, reloading InfoWindow', item)
		for info in self.get_item_list('main_list'):
			if isinstance(info, InfoItem):
				info.reload()
				continue
		louie_send('main_list', sender=self, action='reset', value=self['main_list'])

	def clear(self):
		InfoMenu.clear(self)
		ContextMenu.clear(self.rate_menu)



class AudioItemInfoMenu(MediaItemInfoMenu):
	__doc__ = ' Information menu for a AudioItem '
	def __init__(self, item, name='AudioItem information menu'):
		data = [InfoItem(item, _('Title'), 'metadata_title', True), InfoItem(item, _('Artist'), 'author', True), InfoItem(item, _('Genre'), 'genre', True), InfoItem(item, _('Album'), 'album', True), InfoItem(item, _('Track'), 'track', True), InfoItem(item, _('Year'), 'year', True), InfoItem(item, _('Format'), 'audio_codec'), InfoItem(item, _('Bitrate'), 'bitrate'), InfoItem(item, _('Duration'), 'duration'), InfoItem(item, _('Size'), 'size'), InfoItem(item, _('Belongs to playlist'), 'playlists'), InfoItem(item, _('Import date'), 'date')]
		MediaItemInfoMenu.__init__(self, item, data, name)



class VideoItemInfoMenu(MediaItemInfoMenu):
	__doc__ = ' Information menu for a VideoItem '
	def __init__(self, item, name='VideoItem information menu'):
		data = [InfoItem(item, _('Size'), 'size'), InfoItem(item, _('Codec'), 'video_codec'), InfoItem(item, _('Resolution'), 'resolution'), InfoItem(item, _('Sound track'), 'nrAudioChannels'), InfoItem(item, _('Artist'), 'author')]
		if item['class'].endswith('tvRecord'):
			data.append(InfoItem(item, _('Record date'), 'recordedStartDateTime'))
		else:
			data.append(InfoItem(item, _('Importation date'), 'date'))
		data.append(InfoItem(item, _('Cover'), 'cover'))
		MediaItemInfoMenu.__init__(self, item, data, name)
		self._getitems_keywords['hd_info_icon'] = self._get_hd_info_icon
		self._getitems_keywords['snd_info_icon'] = self._get_snd_info_icon

	def _selection_changed(self, item):
		MediaItemInfoMenu._selection_changed(self, item)
		louie_send('hd_info_icon', sender=self, action='update', value=self._get_hd_info_icon())
		louie_send('snd_info_icon', sender=self, action='update', value=self._get_snd_info_icon())

	def _get_hd_info_icon(self):
		ico = None
		if self.item['height']:
			if int(self.item['height']) > 700:
				ico = 'tvplayer_videoformathd.png'
		return ico

	def _get_snd_info_icon(self):
		ico = None
		if self.item['nrAudioChannels']:
			if int(self.item['nrAudioChannels']) > 5:
				ico = 'tvplayer_audio51.png'
		return ico



class ImageItemInfoMenu(MediaItemInfoMenu):
	__doc__ = ' Information menu for a ImageItem '
	def __init__(self, item, name='ImageItem information menu'):
		data = [InfoItem(item, _('Size'), 'size'), InfoItem(item, _('Resolution'), 'resolution'), InfoItem(item, _('Camera Model'), 'exif_model')]
		MediaItemInfoMenu.__init__(self, item, data, name)



class NetFeedItemInfoMenu(MediaItemInfoMenu):
	__doc__ = 'Information menu for NetFeedItem.'
	def __init__(self, item, name='NetFeedItem information menu'):
		data = [InfoItem(item, _('Link'), 'link'), InfoItem(item, _('URI'), 'uri')]
		MediaItemInfoMenu.__init__(self, item, data, name)



class NetItemInfoMenu(MediaItemInfoMenu):
	__doc__ = 'Information menu for NetItem.'
	def __init__(self, item, name='NetItem information menu'):
		data = [InfoItem(item, _('Author'), 'author'), InfoItem(item, _('Link'), 'link'), InfoItem(item, _('URI'), 'uri')]
		MediaItemInfoMenu.__init__(self, item, data, name)



class DirItemInfoMenu(MediaItemInfoMenu):
	__doc__ = ' Information menu for a DirItem '
	def __init__(self, item, name='DirItem information menu'):
		data = [InfoItem(item, _('Number of files'), 'childs'), InfoItem(item, _('Creation date'), 'date')]
		MediaItemInfoMenu.__init__(self, item, data, name)



class PlayListItemInfoMenu(MediaItemInfoMenu):
	__doc__ = ' Information menu for a PlayListItem '
	def __init__(self, item, name='PlayList information menu'):
		data = [InfoItem(item, _('Number of tracks'), 'childs'), InfoItem(item, _('Missing tracks'), 'missing'), InfoItem(item, _('Creation date'), 'date')]
		MediaItemInfoMenu.__init__(self, item, data, name)



class MarkerListInfoMenu(MediaItemInfoMenu):
	__doc__ = ' Information menu for the markerlist '
	def __init__(self, item, name='MarkerList information menu'):
		data = []
		MediaItemInfoMenu.__init__(self, item, data, name)



item_info_menu_dict = {'video': VideoItemInfoMenu, 'iso_dvd': VideoItemInfoMenu, 'audio': AudioItemInfoMenu, 'image': ImageItemInfoMenu, 'net_feed': NetFeedItemInfoMenu, 'net': NetItemInfoMenu, 'dir': DirItemInfoMenu, 'playlist': PlayListItemInfoMenu}
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb774290c>}
from __future__ import absolute_import
from time import localtime, strftime
from peewee.messages import send as louie_send
from pygui.eventmanager.menus import InfoMenuEventHandler, ChannelInfoMenuEventHandler
from pygui.facilities.l10n import get_date_format
from pygui.item.core import ActionItem, Item
from pygui.item.info import InfoItem, RecordActivationItem, ProtectionsActionItem, ParentalRatingActionItem
from pygui.config import user_config
from .core import ContextMenu
from peewee.formatters import seconds_to_hhmm
from peewee.debug import GET_LOGGER
log = GET_LOGGER(__name__)
class InfoMenu(ContextMenu):
	__doc__ = 'Generic information menu.'
	def __init__(self, item, data, name='Media information menu', eventhandler=None, type='media_info'):
		if not eventhandler:
			pass
		self.eventhandler = eventhandler
		ContextMenu.__init__(self, name, type=type)
		self.item = item
		self._getitems_keywords.update({'titles_list': (lambda : self.get_item_list('titles_list'))})
		if not data:
			pass
		self.set_items(data, 'main_list')
		self._set_options_list()
		titles = []

	def execute_selected(self):
		try:
			self.selected.execute()
		except AttributeError:
			pass



class ChannelInfoMenu(InfoMenu):
	__doc__ = 'Information menu for a ChannelItem.'
	def __init__(self, item, name='Channel information menu'):
		data = [InfoItem(item, _('Favorites list'), 'favorite_list', False), InfoItem(item, _('Conditonal Access Status'), 'cas', False)]
		InfoMenu.__init__(self, item, data, name, ChannelInfoMenuEventHandler(self), type='tv_info')



class TVInfoMenu(InfoMenu):
	__doc__ = 'Information menu for the All Channels List.'
	def __init__(self, item, name='Full channels list information menu'):
		info = {'last_scan_date': strftime(get_date_format(), localtime(user_config['tv']['last_scan_time']))}
		data = [InfoItem(item, _('Number of channels'), 'childCount', False), InfoItem(info, _('Latest scan date'), 'last_scan_date', False)]
		if user_config['security']['parental_control'] and user_config['security']['parent_mode']:
			data.extend((ProtectionsActionItem(item, self, _('Hidden')), ParentalRatingActionItem(item, self, _('Rating'))))
		InfoMenu.__init__(self, item, data, name, type='tv_info')



class ScheduledRecordInfoMenu(InfoMenu):
	__doc__ = 'Information menu for a ScheduledRecordItem.'
	def __init__(self, item, name='Scheduled Record information menu'):
		rec_info = {'start_date': strftime(_('%A %d %B'), localtime(item.record.start_time)), 'start_time': seconds_to_hhmm(item.record.start_time), 'end_time': seconds_to_hhmm(item.record.stop_time)}
		data = [InfoItem(rec_info, _('Date'), 'start_date', False), InfoItem(rec_info, _('Start time'), 'start_time', False), InfoItem(rec_info, _('End time'), 'end_time', False)]
		try:
			repeat_info = {'period': item.period, 'remaining_count': item.remaining_count}
			data.extend([InfoItem(repeat_info, _('Repeat'), 'period', False), InfoItem(repeat_info, _('Remaining recordings'), 'remaining_count', False)])
			if item.remaining_count > 1:
				data.append(RecordActivationItem(item, self, _('Activation')))



class ScheduledRecordRootInfoMenu(InfoMenu):
	__doc__ = 'Information menu for the ScheduledRecordRootItem.'
	def __init__(self, item, name='Scheduled Records Root information menu'):
		all_recs = item.browse()
		info = {'num_records': len(all_recs)}
		data = [InfoItem(info, _('Number of scheduled recordings'), 'num_records', False)]
		if all_recs:
			next_record = all_recs[0].record
			values = {'start_time': strftime('%Y-%m-%d %H:%M', localtime(next_record.start_time))}
			data.append(InfoItem(values, _('Next recording on'), 'start_time', False))
		InfoMenu.__init__(self, item, data, name, type='tv_info')



class RatingInfoMenu(ContextMenu):
	__doc__ = ' Menu to display available rating choices over InfoMenu '
	def __init__(self, item, parent_menu, name='Media Rating menu', eventhandler=None, type='rating_info'):
		if not eventhandler:
			pass
		self.eventhandler = eventhandler
		ContextMenu.__init__(self, name, type=type)
		self.item = item
		self.parent_menu = parent_menu
		self.action_container = ParentalRatingActionItem(item, self, _('Rating'))
		if not [self.action_container]:
			pass
		self.set_items([self.action_container], 'main_list')
		self._set_options_list()
		self.focus_next()

	def focus_previous(self):
		pass

	def get_current_rating(self):
		return self.action_container.name

	def execute_selected(self):
		self.selected.execute()
		self.hide()
		self.parent_menu.rating_callback()

	def clear(self):
		pass



class MediaItemInfoMenu(InfoMenu):
	__doc__ = ' Defines common methods for accessing wymedia attributes '
	def __init__(self, item, data, name):
		self.rating_launcher = None
		if user_config['security']['parental_control'] and user_config['security']['parent_mode'] and data:
			self.rate_menu = RatingInfoMenu(item, self)
			current_rating = self.rate_menu.get_current_rating()
			rating_launcher = ActionItem(current_rating, type_='info', menu=self, display_type=None, action=self.show_rating, args=(), kwargs={})
			rating_launcher.title = _('Rating')
			rating_launcher.field = 'rating'
			data.append(rating_launcher)
			self.rating_launcher = rating_launcher
		InfoMenu.__init__(self, item, data, name, type='media_info')
		def self._getitems_keywords['hd_info_icon']():
			return None

		def self._getitems_keywords['snd_info_icon']():
			return None

		log.debug('InfoWindow for %s: %s', item, item.wymedia_resource)
		try:
			item.watch(self._selection_changed)
			item.async_media_update()
		except AttributeError:
			log.warn('%s.watch failed !', item)
		return None

	def select(self, item, list_name=None, force_pos=False):
		ret = ContextMenu.select(self, item, list_name, force_pos)
		if ret and self.active_list == 'main_list' and self.rating_launcher == self.selected:
			self.execute_selected()

	def show_rating(self):
		self.rate_menu.show()

	def rating_callback(self):
		self.selected.name = self.rate_menu.get_current_rating()
		louie_send('main_list', sender=self, action='reset', value=self['main_list'], position=self.selected_pos)
		self.rate_menu = RatingInfoMenu(self.item, self)

	def _selection_changed(self, item):
		log.debug('%s changed, reloading InfoWindow', item)
		for info in self.get_item_list('main_list'):
			if isinstance(info, InfoItem):
				info.reload()
				continue
		louie_send('main_list', sender=self, action='reset', value=self['main_list'])

	def clear(self):
		InfoMenu.clear(self)
		ContextMenu.clear(self.rate_menu)



class AudioItemInfoMenu(MediaItemInfoMenu):
	__doc__ = ' Information menu for a AudioItem '
	def __init__(self, item, name='AudioItem information menu'):
		data = [InfoItem(item, _('Title'), 'metadata_title', True), InfoItem(item, _('Artist'), 'author', True), InfoItem(item, _('Genre'), 'genre', True), InfoItem(item, _('Album'), 'album', True), InfoItem(item, _('Track'), 'track', True), InfoItem(item, _('Year'), 'year', True), InfoItem(item, _('Format'), 'audio_codec'), InfoItem(item, _('Bitrate'), 'bitrate'), InfoItem(item, _('Duration'), 'duration'), InfoItem(item, _('Size'), 'size'), InfoItem(item, _('Belongs to playlist'), 'playlists'), InfoItem(item, _('Import date'), 'date')]
		MediaItemInfoMenu.__init__(self, item, data, name)



class VideoItemInfoMenu(MediaItemInfoMenu):
	__doc__ = ' Information menu for a VideoItem '
	def __init__(self, item, name='VideoItem information menu'):
		data = [InfoItem(item, _('Size'), 'size'), InfoItem(item, _('Codec'), 'video_codec'), InfoItem(item, _('Resolution'), 'resolution'), InfoItem(item, _('Sound track'), 'nrAudioChannels'), InfoItem(item, _('Artist'), 'author')]
		if item['class'].endswith('tvRecord'):
			data.append(InfoItem(item, _('Record date'), 'recordedStartDateTime'))
		else:
			data.append(InfoItem(item, _('Importation date'), 'date'))
		data.append(InfoItem(item, _('Cover'), 'cover'))
		MediaItemInfoMenu.__init__(self, item, data, name)
		self._getitems_keywords['hd_info_icon'] = self._get_hd_info_icon
		self._getitems_keywords['snd_info_icon'] = self._get_snd_info_icon

	def _selection_changed(self, item):
		MediaItemInfoMenu._selection_changed(self, item)
		louie_send('hd_info_icon', sender=self, action='update', value=self._get_hd_info_icon())
		louie_send('snd_info_icon', sender=self, action='update', value=self._get_snd_info_icon())

	def _get_hd_info_icon(self):
		ico = None
		if self.item['height']:
			if int(self.item['height']) > 700:
				ico = 'tvplayer_videoformathd.png'
		return ico

	def _get_snd_info_icon(self):
		ico = None
		if self.item['nrAudioChannels']:
			if int(self.item['nrAudioChannels']) > 5:
				ico = 'tvplayer_audio51.png'
		return ico



class ImageItemInfoMenu(MediaItemInfoMenu):
	__doc__ = ' Information menu for a ImageItem '
	def __init__(self, item, name='ImageItem information menu'):
		data = [InfoItem(item, _('Size'), 'size'), InfoItem(item, _('Resolution'), 'resolution'), InfoItem(item, _('Camera Model'), 'exif_model')]
		MediaItemInfoMenu.__init__(self, item, data, name)



class NetFeedItemInfoMenu(MediaItemInfoMenu):
	__doc__ = 'Information menu for NetFeedItem.'
	def __init__(self, item, name='NetFeedItem information menu'):
		data = [InfoItem(item, _('Link'), 'link'), InfoItem(item, _('URI'), 'uri')]
		MediaItemInfoMenu.__init__(self, item, data, name)



class NetItemInfoMenu(MediaItemInfoMenu):
	__doc__ = 'Information menu for NetItem.'
	def __init__(self, item, name='NetItem information menu'):
		data = [InfoItem(item, _('Author'), 'author'), InfoItem(item, _('Link'), 'link'), InfoItem(item, _('URI'), 'uri')]
		MediaItemInfoMenu.__init__(self, item, data, name)



class DirItemInfoMenu(MediaItemInfoMenu):
	__doc__ = ' Information menu for a DirItem '
	def __init__(self, item, name='DirItem information menu'):
		data = [InfoItem(item, _('Number of files'), 'childs'), InfoItem(item, _('Creation date'), 'date')]
		MediaItemInfoMenu.__init__(self, item, data, name)



class PlayListItemInfoMenu(MediaItemInfoMenu):
	__doc__ = ' Information menu for a PlayListItem '
	def __init__(self, item, name='PlayList information menu'):
		data = [InfoItem(item, _('Number of tracks'), 'childs'), InfoItem(item, _('Missing tracks'), 'missing'), InfoItem(item, _('Creation date'), 'date')]
		MediaItemInfoMenu.__init__(self, item, data, name)



class MarkerListInfoMenu(MediaItemInfoMenu):
	__doc__ = ' Information menu for the markerlist '
	def __init__(self, item, name='MarkerList information menu'):
		data = []
		MediaItemInfoMenu.__init__(self, item, data, name)



item_info_menu_dict = {'video': VideoItemInfoMenu, 'iso_dvd': VideoItemInfoMenu, 'audio': AudioItemInfoMenu, 'image': ImageItemInfoMenu, 'net_feed': NetFeedItemInfoMenu, 'net': NetItemInfoMenu, 'dir': DirItemInfoMenu, 'playlist': PlayListItemInfoMenu}
